package com.three.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.three.entity.Shaftchoose;
import com.three.mapper.ShaftchooseMapper;
import com.three.service.ShaftChooseService;
import com.three.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShaftChooseServiceImpl implements ShaftChooseService {
    @Autowired
    private ShaftchooseMapper shaftchooseMapper;
    @Override
    public R list() {
       List<Shaftchoose> all = shaftchooseMapper.list();
        return R.ok(all);
    }



    @Override
    public R getShaftChooseAll(Integer pageNum ,Integer pageSize ,Shaftchoose shaftchooses) {
        PageHelper.startPage(pageNum,pageSize);
        List<Shaftchoose> shaftchooseList= shaftchooseMapper.selectShaftChooseAll(shaftchooses);
        PageInfo<Shaftchoose> pageInfo = new PageInfo<>(shaftchooseList);
        return R.ok(pageInfo);
    }
//添加
    @Override
    public R add(Shaftchoose shaftchoose) {
        int i = shaftchooseMapper.insertSelective(shaftchoose);
        if (i>0){
            return R.ok();
        }
        return R.error("添加失败");
    }
//修改
    @Override
    public R edit(Shaftchoose shaftchoose) {
        int i = shaftchooseMapper.updateByPrimaryKeySelective(shaftchoose);
        if (i>0){
            return R.ok();
        }
        return R.error("修改失败");
    }

    @Override
    public R delete(Integer shaftchooseid) {
        int i = shaftchooseMapper.deleteByPrimaryKey(shaftchooseid);
        if (i>0){
            return R.ok();
        }
        return R.error("删除失败");
    }


}
